<template>
  <div class="panel-3 card-common-cls" :class="{'mask-cls': maskable}" @click="click2Drag">
    <p :style="{
        width: '100%',
        fontWeight: fontWeight,
        fontSize: '16px',
        textAlign: alignment,
      }" v-html="item.text || `占位符`"></p>
  </div>
</template>

<script>
  export default {
    props: {
      item: Object,
      maskable: {
        type: Boolean,
        default: true,
      },
    },
    computed: {
      fontWeight() {
        // desc / title
        let _type = this.item && this.item.type || 'desc';
        let _fontWeight = 'normal';
        _fontWeight = _type === 'title' ? 'bold' : 'normal';
        return _fontWeight;
      },
      alignment() {
        // 0表示左对齐，1表示居中，2表示右对齐
        let _type = this.item && this.item.text_alignment || '0';
        switch(_type) {
          case '0':
            return 'left';
          case '1':
            return 'center';
          case '2':
            return 'right';
          default:
            return 'left';
        }
      },
    },
    methods: {
      click2Drag() {
        // console.log(e);
      },
    },
  }
</script>

<style lang="scss" scoped>
  .mask-cls::before {
    position: absolute;
    content: '';
    width: 100%;
    height: 100%;
    z-index: 999;
  }

  .panel-3 {
    display: flex;
    align-items: center;
    min-height: 50px;
  }
  .card-common-cls {
    position: relative;
    width: 100%;
    max-width: 375px;
    z-index: 0;

    img {
      display: block;
      width: 100%;
      height: 100%;
      object-fit: contain;
    }
  }
</style>
